/* 
 * Copyright (C) 2014 Ningbo Yuanqun Inc., All Rights Reserved. 
 */
package com.yuanqunsoft.alimigration.engine.vo;

import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.yuanqunsoft.alimigration.common.ParseEngineType;
import com.yuanqunsoft.alimigration.engine.ParseManager;

@JsonIgnoreProperties(ignoreUnknown=true)
public final class RuleImpl implements Serializable {

    /**
	 * 
	 */
    private static final long serialVersionUID = 9123825915415005984L;

    @JsonProperty(value = "parseEngineType")
    private ParseEngineType engineType;

    @JsonProperty(value = "className")
    private String implClassName;
    
    @JsonProperty(value = "rulName")
    private String ruleName;

    public String getImplClassName() {
        return implClassName;
    }

    public void setImplClassName(String implClassName) {
        this.implClassName = implClassName;
    }

    public String getRuleName() {
        return ruleName;
    }

    public void setRuleName(String ruleName) {
        this.ruleName = ruleName;
    }

    public ParseEngineType getEngineType() {
        return engineType;
    }

    public void setEngineType(ParseEngineType engineType) {
        this.engineType = engineType;
    }

    @Override
    public String toString() {
        return "RuleImpl [engineType=" + engineType + ", implClassName=" + implClassName + ", ruleName="
                + ruleName + "]";
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((engineType == null) ? 0 : engineType.hashCode());
        result = prime * result + ((implClassName == null) ? 0 : implClassName.hashCode());
        result = prime * result + ((ruleName == null) ? 0 : ruleName.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        RuleImpl other = (RuleImpl) obj;
        if (engineType != other.engineType)
            return false;
        if (implClassName == null) {
            if (other.implClassName != null)
                return false;
        } else if (!implClassName.equals(other.implClassName))
            return false;
        if (ruleName == null) {
            if (other.ruleName != null)
                return false;
        } else if (!ruleName.equals(other.ruleName))
            return false;
        return true;
    }
    
    @JsonAnySetter
    private void handler(String key,Object value){
        if(key.equals("parseEngineType")){
            engineType=ParseEngineType.valueOf((int)value);
        }
    }

}
